package com.satyam.smooth.dao.exception;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 *
 * @author satyam
 */
public class DAOException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public DAOException() {
        super();
    }

    public DAOException(Throwable cause) {
        super(cause);
    }

    public DAOException(String message, Throwable cause) {
        super(getDetailMessage(message, cause));
        this.setStackTrace(new StackTraceElement[0]);
    }

    private static String getDetailMessage(String message, Throwable cause) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.println(message);
        pw.print("Caused by: ");
        cause.printStackTrace(pw);
        return sw.toString();
    }

}
